Skip to main content

Workflow Human Template

The Workflow Human template demonstrates how BindAI can pause workflow execution by creating a HumanTask and placing the workflow context into a waiting state. The HumanTaskNode is designed for human-in-the-loop workflows where an external interface or application can inspect the created task and handle the human interaction.

Purpose

This template demonstrates how to:
  • create a human task
  • associate the task with a workflow instance
  • associate the task with a workflow node
  • store the task in the workflow context
  • pause workflow execution using the waiting state
  • configure an optional assignee
  • configure an optional form
The node provides the workflow-engine side of human interaction. The actual user interface and task-completion mechanism are external to the node.

Workflow Structure

A workflow can place a Human Task node between normal workflow nodes.
When the Human Task node executes, it creates a task and marks the workflow context as waiting.

Human Task Node

The implementation is provided by HumanTaskNode. Conceptually:
The node accepts four configuration values:

Task Creation

When the node executes, it creates a new HumanTask. The task receives a generated UUID.
The task records:
  • task ID
  • workflow instance ID
  • node ID
  • creation timestamp
Conceptually:

Workflow Context

The newly created task is stored in the workflow context.
This allows the currently executing workflow instance to expose the task through its runtime context.

Waiting State

After creating the task, the node sets:
The workflow therefore enters a waiting state.
The executor can use this state to stop normal execution until the workflow is resumed.

External Task Handling

HumanTaskNode does not provide a user interface. The task can instead be consumed by an external system such as:
  • a web application
  • an administrative dashboard
  • an approval interface
  • a mobile application
  • an internal task-management system
The workflow package is responsible for creating the task and entering the waiting state. The external application is responsible for presenting the task to a human.

Assignee

A Human Task may optionally specify an assignee. Example:
The assignee is stored on the node as:
The implementation does not itself perform assignment or notification.

Form

A Human Task may also specify an optional form identifier. Example:
The form value is stored on the node:
The node does not render or process the form itself.

Task Lifecycle

The implemented lifecycle is limited to task creation and entering the waiting state.
Task completion and workflow resumption are handled outside the HumanTaskNode implementation.

Workflow Instance Association

Every created task is associated with the currently executing workflow instance.
This allows external systems to identify which workflow execution produced the task. Conceptually:

Node Association

The generated task also records the ID of the node that created it.
This allows the task to be associated with the specific Human Task node within the workflow.

Unique Task IDs

Every execution creates a new task ID using Python’s UUID generator.
Therefore, each created task receives a unique identifier.

Serialization

HumanTaskNode extends the normal workflow-node serialization. Its serialized representation includes:
This allows the optional human-task configuration to be persisted with the workflow definition.

Loading Configuration

The node can restore its human-task configuration from serialized data. The implementation reads:
If either value is missing, it remains None.

Human + AI Workflow

A common workflow pattern is:
For example, an AI agent may generate a document and then create a human task for review. The Human Task node does not perform the review itself. It creates the task that an external system can present to the reviewer.

Human Tasks vs Conditions

These nodes serve different purposes. A workflow can combine both patterns. For example:
The exact decision and resume mechanism depends on the surrounding application and workflow implementation.

Human Tasks vs Loops

Human Tasks and loops also have different purposes. A loop repeats automatically according to workflow state, while a Human Task introduces an external waiting point.

Example

A document-review workflow might look like:
When the Human Review node executes:
An external application can then inspect the task and provide the human interaction.

Important Implementation Boundary

The HumanTaskNode implementation does not:
  • approve a task
  • reject a task
  • collect form responses
  • notify an assignee
  • render a form
  • mark a task as completed
  • resume the workflow
Those responsibilities belong to surrounding application or execution infrastructure. The node’s implemented responsibility is:

Best Practices

  • Provide a meaningful node_id.
  • Use assignee when an external system needs an intended task owner.
  • Use form to associate a task with an external form definition.
  • Keep task presentation outside the workflow node.
  • Treat context.task as the runtime task created by the node.
  • Ensure the surrounding application provides a mechanism for handling waiting workflows.
  • Keep human interaction logic separate from workflow-definition logic.

Summary

The Workflow Human template demonstrates how BindAI introduces a human interaction point into workflow execution. HumanTaskNode creates a uniquely identified HumanTask, associates it with the current workflow instance and node, stores it in context.task, and sets context.waiting = True. The node does not implement approval, rejection, form handling, notifications, or workflow resumption. Those behaviors are provided by the surrounding workflow and application infrastructure.